/*
 * Created on Apr 11, 2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.vectrics.common.pagelist;


import java.util.List;

import org.apache.log4j.Logger;
import org.vectrics.common.db.Criteria;


public abstract class PageList {
	private int pageSize = 12;
	private Criteria criteria = null;
	protected Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * 
	 */
	public PageList() {
		super();
	}

	/**
	 * @return Returns the pageSize.
	 */
	public final int getPageSize() {
		return pageSize;
	}
	
	abstract public int getTotalElementCount();
	

	public final void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	
	public final int getTotalPages() {
		int total = getTotalElementCount();
		int pages = total / getPageSize();
		if ((pages * getPageSize()) < total) {
			pages++;
		}
		return(pages);		
	}
	
	abstract public List getElements(int start, int end);
	
	//abstract public List getKeys(int startIndex, int endIndex);
	/**
	 * @return Returns the criteria.
	 */
	public Criteria getCriteria() {
		return criteria;
	}

	/**
	 * @param criteria The criteria to set.
	 */
	public void setCriteria(Criteria criteria) {
		this.criteria = criteria;
	}

}
